<template>
	<h-popup :show.sync="show">
		<view class="padding bg-white">
			<view class="cu-form-group margin-top-xs">
				<input name="input" placeholder="输入姓名" placeholder-style="color:#ccc" v-model="ruleForm.name"/>
			</view>
			<view class="cu-form-group">
				<input name="input" placeholder="输入身份证号" placeholder-style="color:#ccc" v-model="ruleForm.identity_code"/>
			</view>
			<view class="btn-wrap margin-top-sm">
				<button class="cu-btn round bg-red" @click="handlePublish">提交审核</button>
			</view>
		</view>
	</h-popup>
</template>

<script>
	import HPopup from "@/components/HPopup"
	export default{
		data(){
			return {
				show:false,
				ruleForm:{
					name:"",
					identity_code:""
				},
				rules:{
					name:[
						{msg:'姓名不能为空',required:true}
					],
					identity_code:[
						{msg:'身份证号码不能为空',required:true}
					]
				}
			}
		},
		components:{
			HPopup
		},
		methods:{
			toggle(){
				this.show=!this.show
			},
			async handlePublish(){
				let res = await this.$h.utils.validateForm(this.ruleForm,this.rules)
				if(res){
					let query={
						...this.ruleForm
					}
					let {code}=await this.$h.api.liveModel.postIdentity(query)
					if(code===1){
						this.toggle()
						this.$h.router.push({
							path:"/pages/publish/liveInfo/liveInfo"
						})
					}else{
						this.toggle()
						this.$h.toast('认证失败')
					}
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btn-wrap {
		height: 80rpx;
		button {
			color: #fff;
			width: 100%;
			height: 80rpx;
			box-sizing: border-box;
			line-height: 80rpx;
			font-size: 28rpx;
			font-weight: 500;
		}
	}
</style>
